#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int stack[30][2];
int top;

int path[8][2] = {
		{-1, -2},
		{+1, -2},
		{-2, -1},
		{+2, -1},
		{-2, +1},
		{+2, +1},
		{-1, +2},
		{+1, +2}
};

int flag[50][50];

int dfs(int r, int c, int p, int q)
{
	flag[r][c] = 1;

	stack[top][0] = r;
	stack[top][1] = c;
	top ++;

	if(top == p * q)
		return 1;

	int rr, cc;
	for(int i = 0;i<8;i++)
	{
		rr = r + path[i][0];
		cc = c + path[i][1];

		if(rr >= 0 && rr < p && cc >= 0 && cc < q && !flag[rr][cc])
			if(dfs(rr, cc, p, q))
				return 1;
	}

	--top;
	flag[r][c] = 0;

	return 0;
}

void solve(int p, int q)
{
	static int cas = 1;
	printf("Scenario #%d:\n", cas ++);
	memset(flag, 0, sizeof(flag));
	top = 0;
	if(dfs(0, 0, p, q))
	{
		for(int k = 0;k<p * q;k++)
		{
			printf("%c%d", 'A' + stack[k][1], stack[k][0] + 1);
		}
		printf("\n\n");
		return;
	}
	printf("impossible\n\n");
}

int main()
{
	freopen("data.in", "r", stdin);
	int p, q;
	int t;
	scanf("%d", &t);
	for(int i = 0;i<t;i++)
	{
		scanf("%d%d", &p, &q);
		solve(p, q);
	}
	return 0;
}
